/**
  *  This file is part of Carma (Retroduction.org).
  *
  *  Carma is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  Carma is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
  *  along with Carma.  If not, see <http://www.gnu.org/licenses/>.
  *
  * Copyright Retroduction.org (c) 2007-2010
  */

package com.retroduction.carma.resolvers;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import junit.framework.TestCase;

public class ClassMatchResolverTestCase extends TestCase {

	public void test_CustomTestCaseSuffix() {

		ClassMatchResolver resolver = new ClassMatchResolver();

		Set<String> input = new HashSet<String>();

		input.add("com.retroduction.carma.test.Class1");
		input.add("com.retroduction.carma.test.Class2");

		resolver.setTestNameSuffix("PussyCat");

		HashMap<String, Set<String>> result = resolver.resolve(input);

		assertEquals(2, result.size());

		assertTrue(result.get("com.retroduction.carma.test.Class1").contains(
				"com.retroduction.carma.test.Class1PussyCat"));

		assertTrue(result.get("com.retroduction.carma.test.Class2").contains(
				"com.retroduction.carma.test.Class2PussyCat"));

	}

	public void test_DefaultTestCaseSuffix() {

		ClassMatchResolver resolver = new ClassMatchResolver();

		Set<String> input = new HashSet<String>();

		input.add("com.retroduction.carma.test.Class1");
		input.add("com.retroduction.carma.test.Class2");

		HashMap<String, Set<String>> result = resolver.resolve(input);

		assertEquals(2, result.size());

		assertTrue(result.get("com.retroduction.carma.test.Class1").contains("com.retroduction.carma.test.Class1Test"));

		assertTrue(result.get("com.retroduction.carma.test.Class2").contains("com.retroduction.carma.test.Class2Test"));
	}
	public void test_CustomTestCasePrefix() {

		ClassMatchResolver resolver = new ClassMatchResolver();

		Set<String> input = new HashSet<String>();

		input.add("com.retroduction.carma.test.Class1");
		input.add("Class2");

		resolver.setTestNameSuffix("");
		resolver.setTestNamePrefix("PussyCat");

		HashMap<String, Set<String>> result = resolver.resolve(input);

		assertEquals(2, result.size());

		assertTrue(result.get("com.retroduction.carma.test.Class1").contains(
				"com.retroduction.carma.test.PussyCatClass1"));

		assertTrue(result.get("Class2").contains(
				"PussyCatClass2"));

	}
}
